/*
 * @Description: jishupu-admin-template
 * @Author: 技术铺<jishupu@qq.com>
 * @Date: 2022-03-03
 */
const { success, error } = require('./utils')

const token = 'jishupu-admin-template-token'
const user = {
  username: 'admin',
  password: 'admin'
}

// 登录模块
module.exports = [
  // 登录
  {
    url: '/v1/login',
    type: 'post',
    response: config => {
      const { username, password } = config.body
      if (user.username === username && user.password === password) {
        return success({ totken: token }, '登录成功。')
      } else {
        return error('登录失败。')
      }
    }
  },
  // 退出
  {
    url: '/v1/logout',
    type: 'get',
    response: _ => {
      return success({}, '已退出登录。')
    }
  }
]
